package jgl.vajra.management.part.splash;

import jgl.vajra.management.R;
import jgl.vajra.management.manager.IntentManager;
import jgl.vajra.management.widget.base.BaseCommonActivity;
import jgl.vajra.management.widget.manager.SPManager;
import jgl.vajra.management.widget.retrofithelper.rxsubscriber.CommonObserver;
import jgl.vajra.management.widget.utils.TimerUtils;

import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;


public class SplashActivity extends BaseCommonActivity {

    @Override
    public int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this).fullScreen(true).statusBarDarkFont(true, 0.2f).hideBar(BarHide.FLAG_HIDE_NAVIGATION_BAR).init();

        TimerUtils.countdown(2).
                subscribe(new CommonObserver<Integer>() {
                    @Override
                    public void onComplete() {
                        super.onComplete();
                        if (SPManager.LoginData.getIsLogin())
                            IntentManager.toHomeActivity(SplashActivity.this);
                        else
                            IntentManager.toLoginActivity(SplashActivity.this);
                        finish();
                    }
                });
    }

    @Override
    protected boolean isNeedLoadStatusBar() {
        return false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {

    }
}
